<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>用户管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="用户,管理">
	<meta http-equiv="description" content="This is my page">
	
	<script type="text/javascript" src="${CONTEXT_PATH}/common/js/divTip.js"></script>
	<script src='${CONTEXT_PATH}/dwr/interface/listTipService.js'></script>
	<script src='${CONTEXT_PATH}/dwr/engine.js'></script>
	<script src='${CONTEXT_PATH}/dwr/util.js'></script>

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="queryUser.action" namespace="/inner/user/">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'系统管理'},{'name':'用户管理'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
    		<table cellspacing="1" width="100%" bgcolor="#CCCCCC">
				<tr bgcolor="#FFFFFF">
					<td align="right" width="10%" class="label">
						用户帐号：
					</td>
					<td align="left" width="23%">
						<s:textfield name="uvo.user.id" id="userId" cssClass="search" cssStyle="width:80%"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						用户名称：
					</td>
					<td align="left" width="23%">
						<s:textfield name="uvo.user.username" id="username" cssClass="search" cssStyle="width:80%" onkeyup="usernameTip()"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						性别：
					</td>
					<td align="left" width="24%">
						<s:select cssClass="search" list='#{"男":"男", "女":"女"}' headerKey="" headerValue="--请选择--" cssStyle="width:120" name="uvo.user.sex" id="sex" value="uvo.user.sex"></s:select>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td align="right" class="label">
						所属部门：
					</td>
					<td align="left">
						<s:select list="deptList" listKey="id" listValue="deptName" headerKey="" headerValue="--请选择--" cssClass="search" cssStyle="width:120" name="uvo.user.dept.id" id="deptId" value="uvo.user.dept.id"></s:select>
					</td>
					<td align="right" class="label">
						所属幼儿园：
					</td>
					<td align="left">
						<s:select list="kgList" headerKey="" headerValue="--请选择--" listKey="id" listValue="kgName" name="uvo.user.kindergarten.id" id="kgId" cssClass="search" cssStyle="width:80%"></s:select>
					</td>
					<td align="right" class="label">
						使用情况：
					</td>
					<td align="left">
						<s:radio list='#{"":"全部", "use":"已审核", "lock":"已锁定"}' name="uvo.user.useType" id="useType" value="uvo.user.useType" cssClass="search"></s:radio>
					</td>
				</tr>
			</table>
    		
    		<table cellspacing="0" width="100%">
				<tr>
					<td align="left">
						<my:hasPermission privilegeId="searchUser">
						<input type="button" value="查询" class="btn" onclick="searchThis()"/>
						</my:hasPermission>
						<my:hasPermission privilegeId="addUser">
						<input type="button" value="新增" class="btn" onclick="toAddUser()"/>
						</my:hasPermission>
						<my:hasPermission privilegeId="delUser">
						<input type="button" value="删除" class="btn" onclick="delUser()"/>
						</my:hasPermission>
						<my:hasPermission privilegeId="useUser">
						<input type="button" value="批量审核" class="btn" onclick="useUsersOrNot('use')" />
						</my:hasPermission>
						<my:hasPermission privilegeId="lockUser">
						<input type="button" value="批量锁定" class="btn" onclick="useUsersOrNot('lock')" />
						</my:hasPermission>
						<input type="button" value="重置" class="btn" onclick="resetSearch()" />
					</td>
				</tr>
			</table>
    		
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr class="tableHead" align="center">
    				<td width="4%">
    					<input type="checkbox" onclick="cbCheck(this, 'userIds')" />
    				</td>
    				<td width="5%">
    					序号
    				</td>
    				<td width="10%">
    					帐号
    				</td>
    				<td width="12%">
    					用户名称
    				</td>
    				<td width="8%">
    					性别
    				</td>
    				<td width="12%">
    					所属部门
    				</td>
    				<td width="12%">
    					所属幼儿园
    				</td>
    				<td width="10%">
    					使用情况
    				</td>
    				<td width="20%">
    					操作
    				</td>
    			</tr>
    			<s:iterator value="lp.list" status="s">
    				<tr align="center"
    					<s:if test="#s.index%2==0">class="tableRow2" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow2'"</s:if>
						<s:else>class="tableRow1" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow1'"</s:else>
    				>
    					<td>
    						<input name="userIds" type="checkbox" value="<s:property value='id'/>" />
    					</td>
    					<td>
    						<s:property value="(pager.thisPage - 1) * pager.pageSize + #s.index + 1" />
    					</td>
    					<td>
    						<s:property value="id"/>
    					</td>
    					<td>
    						<s:property value="username"/>
    					</td>
    					<td>
    						<s:property value="sex"/>
    					</td>
    					<td>
    						<s:property value="deptName"/>
    					</td>
    					<td>
    						<s:property value="kgName"/>
    					</td>
    					<td>
    						<s:if test='@com.pk.platform.util.constant.Constant@USE.equals(useType)'>
    							已审核
    						</s:if>
    						<s:elseif test='@com.pk.platform.util.constant.Constant@LOCK.equals(useType)'>
    							<font color="red">已锁定</font>
    						</s:elseif>
    					</td>
    					<td>
    						<s:if test='!@com.pk.platform.util.constant.Constant@POWER_USER.equals(id) || operateUser == true'>
    						<my:hasPermission privilegeId="updateUser">
    						<a href="javascript:toUpdateUser('<s:property value="id" />')">修改</a>
    						</my:hasPermission>
    						<my:hasPermission privilegeId="assignRole">
    						<a href="javascript:toAssignRole('<s:property value="id" />')">分配角色</a>
    						</my:hasPermission>
    						<my:hasPermission privilegeId="resetPassword">
    						<a href="javascript:toResetPassword('<s:property value="id" />')">重置密码</a>
    						</my:hasPermission>
    						</s:if>
    					</td>
    				</tr>
    			</s:iterator>
   				<jsp:include page="/common/pager/pager.jsp">
					<jsp:param name="formName" value="frm" />
					<jsp:param name="id" value="1" />
				</jsp:include>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function searchThis()
    {
    	$('#thisPage').val(1);
    	document.forms['frm'].submit();
    }
    
    function toAddUser()
    {
    	var url = '${CONTEXT_PATH}/inner/user/toAddUser.action';
    	openWin(url, 700, 350, 'yes', 'yes');
    }
    
    function toUpdateUser(id)
    {
    	var url = '${CONTEXT_PATH}/inner/user/toUpdateUser.action?user.id=' + id;
    	openWin(url, 700, 350, 'yes', 'yes');
    }
    
    function delUser()
    {
    	if(hasCheck('userIds') == false)
    		return;
    	showConfirm('确认删除？', function(v){
    		if(v == true)
    		{
    			document.forms['frm'].action = '${CONTEXT_PATH}/inner/user/delUsers.action';
    			document.forms['frm'].submit();
    		}
    	});
    }
    
    function toAssignRole(id)
    {
    	var url = '${CONTEXT_PATH}/inner/user/toAssignRole.action?user.id=' + id;
    	openWin(url, 620, 300, 'yes', 'yes');
    }
    
    function toResetPassword(id)
    {
    	var url = '${CONTEXT_PATH}/inner/user/toResetPassword.action?user.id=' + id;
    	showMd(url, 350, 250);
    }
    
    function useUsersOrNot(v)
    {
    	document.forms['frm'].action = '${CONTEXT_PATH}/inner/user/useUsersOrNot.action?user.useType=' + v;
    	document.forms['frm'].submit();
    }
    
    function usernameTip()
    {
    	var username = $('#username');
    	showListTip('username', 'p_user', 'username', '', username.width(), 10);
    }
    </script>
  </body>
</html>
